package com.gosophia.resource.action;

import java.net.URLEncoder;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.gosophia.commons.web.action.BaseSupportAction;
import com.gosophia.commons.web.logAnnotation.LogRecord;
import com.gosophia.resourcePermission.dto.ResourcePermissionDTO;
import com.gosophia.resourcePermission.ws.ResourcePermissionWebService;
import com.opensymphony.xwork2.ActionContext;

/**
 * 修改资源集
 * 
 * @author zhao_yanfang
 * 
 */
@Controller("updateResourceAction")
@Scope("prototype")
public class UpdateResourceAction extends BaseSupportAction {

	private static final Log logger = LogFactory
	.getLog(ShowResourcePageAction.class);
	private ResourcePermissionDTO resourcePermissionDTO;
	@Autowired
	private ResourcePermissionWebService resourcePermissionWebService;

	@LogRecord(eventAction="数据权限规则-更新资源集",eventTarget="resourcePermissionDTO")
	public String _execute() throws Exception {
		logger.info("修改资源集，名称为:"+resourcePermissionDTO.getResourceName()+";匹配策略为:"+resourcePermissionDTO.getResourceMatch());
		resourcePermissionWebService.updateResource(resourcePermissionDTO);
		super.getRequestResult().setMessage("修改数据集成功");
		super.getRequestResult().setRsltCode("0");
		ActionContext.getContext().getSession().put("_lastOpResult", super.getRequestResult());
		return SUCCESS;
	}

	public ResourcePermissionDTO getResourcePermissionDTO() {
		return resourcePermissionDTO;
	}

	public void setResourcePermissionDTO(ResourcePermissionDTO resourcePermissionDTO) {
		this.resourcePermissionDTO = resourcePermissionDTO;
	}
	
}
